package com.haitonghop.main;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.haitonghop.R;
import com.haitonghop.data.GreatAppItem;
import com.haitonghop.utils.GlobalData;

public class GreatAppRender extends ArrayAdapter<GreatAppItem>{

	private ArrayList<GreatAppItem> appList = null;

	public GreatAppRender(Context context, int resource, int textViewResourceId, ArrayList<GreatAppItem> objects) {
		super(context, resource, textViewResourceId, objects);
		this.appList = objects;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub

		LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View rowHeader = inflater.inflate(R.layout.great_app_item_render, parent, false);
		rowHeader.setPadding(2,2,2,2);

		TextView header = (TextView) rowHeader.findViewById(R.id.title);
		TextView des = (TextView) rowHeader.findViewById(R.id.des);
		final ImageView imageView = (ImageView) rowHeader.findViewById(R.id.avatarView);


		GreatAppItem item = appList.get(position);

		header.setText(item.appName);
		des.setText(item.des);

		String url =item.avatar;
		GlobalData.mAQ.id(imageView).image(url, GlobalData.opt_avatar);

		return rowHeader;
	}
}
